using System;
using System.Collections.Generic;
using UnityEngine;

public class C_敌人AI_幽魂 : C_敌人AI_Base<StateType_Enemy_幽魂, EnemyStateBase_幽魂>, IBoss
{
	[HideInInspector]
	private ItemUI_BossHP _mUI_BossHP;

	[SerializeField]
	private GameObject _拍地板特效Prefab;

	[HideInInspector]
	public GameObject _GO_激光蓄力特效;

	[HideInInspector]
	public GameObject _GO_激光特效;

	public AudioClip _AudioC_攻击音效1;

	[Header("金池长老拥有Start")]
	[HideInInspector]
	public bool _Is飞升;

	public Enemy_生成_金池_僵尸 _僵尸生成器;

	public AudioClip _AudioC_金池长老入场;

	[Header("金池长老拥有End")]
	public bool __;

	private bool _已经触发BGM;

	private float _StartDrag;

	public ItemUI_BossHP _UI_BossHP
	{
		get
		{
			if (_mUI_BossHP == null)
			{
				_mUI_BossHP = MonoSingleton<GameManager>.Instance.F_Get_ItemUI_BossHP();
				_mUI_BossHP._可见性 = false;
				_mUI_BossHP.F_SetVal(_Data._CurrHP, _Data._MaxHP);
				_mUI_BossHP.F_设置名字(_EnemyName);
			}
			return _mUI_BossHP;
		}
		set
		{
			_mUI_BossHP = value;
		}
	}

	public event Action _Boss死亡 = delegate
	{
	};

	public void F_Ani_Play_攻击音效1()
	{
		MonoSingleton<AudioManager>.Instance.F_Play_SFX(_AudioC_攻击音效1);
	}

	private void Start()
	{
		_StartDrag = _Rb2D.drag;
		_GO_激光蓄力特效 = base.transform.Find("激光_蓄力特效").gameObject;
		_GO_激光特效 = base.transform.Find("激光_特效").gameObject;
		F_添加状态();
		ChangeState(StateType_Enemy_幽魂.站立);
	}

	public virtual void F_添加状态()
	{
		_FSM.states = new Dictionary<StateType_Enemy_幽魂, EnemyStateBase_幽魂>
		{
			{
				StateType_Enemy_幽魂.站立,
				new EnemyState_幽魂_站立().Init(this)
			},
			{
				StateType_Enemy_幽魂.散步,
				new EnemyState_幽魂_散步().Init(this)
			},
			{
				StateType_Enemy_幽魂.追击,
				new EnemyState_幽魂_追击().Init(this)
			},
			{
				StateType_Enemy_幽魂.攻击,
				new EnemyState_幽魂_攻击().Init(this)
			},
			{
				StateType_Enemy_幽魂.受击,
				new EnemyState_幽魂_受击().Init(this)
			},
			{
				StateType_Enemy_幽魂.死亡,
				new EnemyState_幽魂_死亡().Init(this)
			}
		};
	}

	public void F_Ani_生成拍地板特效(float size)
	{
		UnityEngine.Object.Instantiate(_拍地板特效Prefab, base.transform.position, Quaternion.identity).transform.localScale = new Vector3(size, size);
	}

	public void F_Ani_屏幕震动(float 持续时间)
	{
		GameSceneController.F_屏幕震动(持续时间, 0.15f, 12);
	}

	protected override void OnTriggerEnter2D(Collider2D collision)
	{
		if (collision.tag == "Player")
		{
			_Is追击中 = true;
			_Tsf_玩家 = collision.transform;
			_Is视野范围内 = true;
			_UI_BossHP._可见性 = true;
			if (!_已经触发BGM)
			{
				_已经触发BGM = true;
				MonoSingleton<AudioManager>.Instance.F_Play_BGM(MonoSingleton<AudioManager>.Instance._AudioC_云宫迅音_战斗);
			}
		}
	}

	private void OnCollisionEnter2D(Collision2D collision)
	{
	}

	private void OnCollisionStay2D(Collision2D collision)
	{
		_ = collision.transform.tag == "Player";
	}

	protected virtual void OnDestroy()
	{
		F_删除血条();
		MonoSingleton<AudioManager>.Instance.F_Play_BGM(MonoSingleton<AudioManager>.Instance._AudioC_黑神话_悟空_BGM);
	}

	public void F_删除血条()
	{
		if (_UI_BossHP != null)
		{
			UnityEngine.Object.Destroy(_UI_BossHP.gameObject);
			_UI_BossHP = null;
		}
	}

	public override void BeAttack(float atk_生命, float atk_僵直, float atk_击退力度, Vector2 atk_Pos, bool atk_Is远程 = false)
	{
		if (!_Is虚幻 && !_Is死亡)
		{
			if (_Cor_受击变色 != null)
			{
				StopCoroutine(_Cor_受击变色);
			}
			_Cor_受击变色 = StartCoroutine(Cor_受击变色());
			_Rb2D.AddForce(100f * base._BeAttack_击退力度 * new Vector2((base.transform.position.x > base._BeAttack_Pos.x) ? 1 : (-1), 0f), ForceMode2D.Impulse);
			_UI_BossHP._可见性 = true;
			base._BeAttack_Pos = atk_Pos;
			base._BeAttack_击退力度 = atk_击退力度;
			_Data._CurrHP -= atk_生命;
			_UI_BossHP.F_SetVal(_Data._CurrHP, _Data._MaxHP);
			if (_Data._CurrHP <= 0f)
			{
				this._Boss死亡();
				ChangeState(StateType_Enemy_幽魂.死亡);
			}
			_Data._Curr僵直数值 += atk_僵直;
			if (_Data._Curr僵直数值 >= _Data._Max僵直数值)
			{
				_Data._Curr僵直数值 = 0f;
				_Data._Max僵直数值 += _Data._僵直数值增长;
				ChangeState(StateType_Enemy_幽魂.受击);
			}
		}
	}

    public void F_监听Boss死亡(Action action)
    {
        _Boss死亡 += action;
    }
}
